# COPYRIGHT_CHUNFENG
include config.mk
include libs.mk
OS ?= LINUX32
CC ?= gcc
CFLAGS += -Wall -Wno-unused-label -Wno-unused-function
LDFLAGS += -Wl,--as-needed
ifeq ($(OS),WIN32)
CFLAGS += -D_WIN32_
else
endif
ifeq ($(DEBUG),y)
CFLAGS += -g
LDFLAGS += -g
else
CFLAGS += -s
LDFLAGS += -s -O2
endif

################################
TARGET = libnautilus-p7zip.so
VER = $(shell cat VERSION)
OBJS = p7zip_helper.o p7zg_cui.o nautilus-p7zip.o nautilus-p7zip-module.o
CFLAGS += -I./include
CFLAGS += $(CFLAGS_LIBCHUNFENG) $(CFLAGS_GTK) $(CFLAGS_NAUTILUS) -fPIC
LDFLAGS += $(LDFLAGS_LIBCHUNFENG) $(LDFLAGS_GTK) -shared -Wl,-soname -Wl,$(TARGET)
ifeq ($(USE_P7ZG_LOG), yes)
CFLAGS += -D_USE_P7ZG_LOG_
endif
################################

all:$(TARGET)

$(TARGET):$(TARGET).$(VER)
ifeq ($(OS),WIN32)
	mv $^ $@
else
	ln -sf $^ $@
endif

$(TARGET).$(VER):$(OBJS)
	$(CC) $^ $(LDFLAGS) -o $@

install:
	mkdir -p $(INSTALL_DIR)/usr/bin
	cp -af ${TARGET} ${TARGET}.${VER} $(INSTALL_DIR)/usr/bin

	
uninstall:
	rm -rf $(INSTALL_DIR)/usr/bin/${TARGET} $(INSTALL_DIR)/usr/bin/${TARGET}.$(VER)

	
clean:
	rm -rf test $(TARGET)  $(TARGET).${VER} *.o

	
.PHONY : all clean install uninstall

